package org.budo.sms.service.zhongke;

import java.util.Map;

import org.budo.support.http.client.Request;
import org.budo.support.http.client.Response;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

/**
 * @author lmw
 */
@Slf4j
@Getter
@Setter
public class BudoZhongkeSmsServiceImpl implements BudoZhongkeSmsService {
    private String userid;

    private String account;

    private String password;

    @Override
    public String sendSms(String to, String template, Map<String, Object> parameters) {
        Request request = new Request();
        request.setUrl("http://14.29.233.42:8088/sms.aspx");
        request.setMethod(Request.POST);
        request.setField("action", "send");
        request.setField("userid", this.getUserid());
        request.setField("account", this.getAccount());
        request.setField("password", this.getPassword());
        request.setField("mobile", to);
        request.setField("content", template);

        Response response = request.execute();

        log.info("#38 response = " + response + ", request = " + request);
        return response.bodyOrToString();
    }
}